<?php
/**
 * 实现的方法
 * TransHistory
 */
require 'config.php';

require 'Lib_btc.php';

//$result = btce_query("Trade", array("pair" => "btc_usd", "type" => "buy", "amount" => 1, "rate" => 10)); //buy 1 BTC @ 10 USD
//$max_order_id
//$result = btce_query("getInfo");
$max_order_id = getMaxOrderId();

$result = btce_query("OrderList",
		array( "count" => 50, "order" => 'ASC', 'from_id'=> $max_order_id, 'active'=>0 ));

if( !empty($result) && $result['success'] == BTC_API_SUCCESS )
{
	$i=0;
	$rows = $result['return'];
	if( !empty($rows) )
	{
		foreach( $rows AS $order_id=>$row )
		{
			$row['order_id'] = $order_id;
			if( !existsOrderAndUpdate($row)  )// update
				insertOrder($row);// insert
			$i++;
		}
	}
	logBtcApiResult('OrderList','获取交易数量：'.$i.'个。');
}
echo "<script>
<!--
setTimeout(function(){location.replace(location.href);},10000);
//-->
</script>";

?>
